<%@page import="com.libweb.model.dto.Member"%>
<%@page import="com.libweb.model.dto.Book"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
    pageEncoding="utf-8"%>

<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8" />
	<title>도서 관리</title>
	<link rel="Stylesheet" href="/libweb/styles/default.css" />
	<link rel="Stylesheet" href="/libweb/styles/input.css" />
	<script type="text/javascript">
		function doDelete(bookno) {
			var ok = confirm("도서를 삭제합니다.");
			if (ok) {
				//삭제처리
				location.href="delete.action?bookno=" + bookno;
			}
		}
	</script>	
			
</head>
<body>

	<div id="pageContainer">
		
		<% pageContext.include("/WEB-INF/views/include/header.jsp"); %>
		
		<div id="inputcontent">
			<br /><br />
		    <div id="inputmain">
		        <div class="inputsubtitle">도서 정보</div>
				<%
				Book book = (Book)request.getAttribute("book");
				%>
		        <table>
		            <tr>
		                <th>도서번호</th>
		                <td><%= book.getBookNo() %></td>
		            </tr>
		            <tr>
		                <th>제목</th>
		                <td><%= book.getTitle() %></td>
		            </tr>
		            <tr>
		                <th>출판사</th>
		                <td><%= book.getPublisher() %></td>
		            </tr>		            
		            <tr>
		                <th>저자</th>
		                <td><%= book.getAuthor() %></td>
		            </tr>
		            <tr>
		                <th>출간일</th>
		                <td><%= book.getPubDate() %></td>
		            </tr>
		            <% Member member = (Member)session.getAttribute("loginuser"); %>	            	            
		            <tr>
		                <th>대여 상태</th>
		                <td><%	if(book.isStatus()) { %>
        					대여 중
        				<%	}else { %>
        					대여 가능</a>
        				<%	} %>
        				</td>
		            </tr>
		            <tr>
		                <th>등록일</th>
		                <td><%= book.getRegDate() %></td>
		            </tr>		            		            		            		            		            
		        </table>
		        <div class="buttons">
		        	<a href="/libweb/book/list.action">[&nbsp;목록&nbsp;]</a>
		        	&nbsp;&nbsp;
		        	<% if(book.isStatus()) {%>
		        		[&nbsp;대여 불가&nbsp;]
		        	<% } else {%>
		        		<a href="/libweb/rent/rentregister.action?bookno=<%=book.getBookNo()%>&memberid=<%=member.getMemberId()%>">[&nbsp;대여 신청&nbsp;]</a>
		        	<% } %>
		        	&nbsp;&nbsp;		        	
		        	<% if(member.getMemberId().equals("admin")) {%>
		        		<a href="/libweb/book/editform.action?bookno=<%=book.getBookNo()%>">[&nbsp;수정&nbsp;]</a>
		        		&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
		        		<a href="javascript:doDelete(<%=book.getBookNo()%>);">[&nbsp;삭제&nbsp;]</a>
		            <% }else { }%>		        	
		        </div>
		    </div>
		</div>   		
	</div>
</body>
</html>